package com.ssy.lingxi.search.api.feign;

import com.ssy.lingxi.common.constant.tree.Node;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.search.api.hystrix.TemplateHystrix;
import com.ssy.lingxi.search.api.model.request.StoreIdListRequest;
import com.ssy.lingxi.search.api.model.request.TemplateCommoditySearchRequest;
import com.ssy.lingxi.search.api.model.response.BrandResponse;
import com.ssy.lingxi.search.api.model.response.CategoryResponse;
import com.ssy.lingxi.search.api.model.response.CommoditySearchResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 模板服务类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/8/1
 */
@FeignClient(value = "search-service", fallback = TemplateHystrix.class)
public interface ITemplateFeign{

    /**
     * 查询商品分类树
     * @param shopId            商城id
     * @param memberId          会员id
     * @param memberRoleId      会员角色id
     */
    @RequestMapping(value = "/search/commodity/template/getCategoryTree", method = RequestMethod.GET)
    Wrapper<List<Node>> getCategoryTree(
            @RequestParam(value = "shopId") Long shopId,
            @RequestParam(value = "memberId", required = false) Long memberId,
            @RequestParam(value = "memberRoleId", required = false) Long memberRoleId);

    /**
     * 查询一级品类信息
     * @param shopId            商城id
     * @param memberId          会员id
     * @param memberRoleId      会员角色id
     */
    @RequestMapping(value = "/search/commodity/template/getFirstCategoryListByMemberId", method = RequestMethod.GET)
    Wrapper<List<CategoryResponse>> getFirstCategoryListByMemberId(
            @RequestParam(value = "shopId") Long shopId,
            @RequestParam(value = "memberId", required = false) Long memberId,
            @RequestParam(value = "memberRoleId", required = false) Long memberRoleId);

    /**
     * 查询二级品类信息
     * @param shopId            商城id
     * @param memberId          会员id
     * @param memberRoleId      会员角色id
     * @param categoryId        品类id
     */
    @RequestMapping(value = "/search/commodity/template/getSecondCategoryListByMemberId", method = RequestMethod.GET)
    Wrapper<List<CategoryResponse>> getSecondCategoryListByMemberId(
            @RequestParam(value = "shopId") Long shopId,
            @RequestParam(value = "memberId", required = false) Long memberId,
            @RequestParam(value = "memberRoleId", required = false) Long memberRoleId,
            @RequestParam(value = "categoryId") Long categoryId);

    /**
     * 通过品类查询会员信息
     * @param shopId            商城id
     * @param categoryId        品类id
     */
    @RequestMapping(value = "/search/commodity/template/getMemberIdByCategory", method = RequestMethod.GET)
    Wrapper<List<Long>> getMemberIdByCategory(
            @RequestParam(value = "shopId") Long shopId,
            @RequestParam(value = "categoryId") Long categoryId);

    /**
     * 查询商品信息
     * @param templateCommoditySearchRequest 请求参数
     */
    @RequestMapping(value = "/search/commodity/template/searchCommodityList", method = RequestMethod.POST)
    Wrapper<PageData<CommoditySearchResponse>> searchCommodityList(@RequestBody TemplateCommoditySearchRequest templateCommoditySearchRequest);

    /**
     * 查询品牌信息
     * @param current 当前页码
     * @param pageSize 每页条数
     * @param customerCategoryId 会员分类id
     * @param categoryId 平台分类id
     * @param memberId 会员id
     * @param name 品牌名称
     * @param idInList 包含
     * @param idNotInList 不包含
     */
    @RequestMapping(value = "/search/commodity/template/getBrandList", method = RequestMethod.GET)
    Wrapper<PageData<BrandResponse>> getBrandList(@RequestParam("current") Integer current, @RequestParam("pageSize") Integer pageSize,
                                                         @RequestParam(value = "shopId", required = false) Long shopId,
                                                         @RequestParam(value = "customerCategoryId",required = false) Long customerCategoryId,
                                                         @RequestParam(value = "categoryId",required = false) Long categoryId,
                                                         @RequestParam(value = "memberId",required = false) Long memberId,
                                                         @RequestParam(value = "memberRoleId",required = false) Long memberRoleId,
                                                         @RequestParam(value = "memberName",required = false) String memberName,
                                                         @RequestParam(value = "name",required = false) String name,
                                                         @RequestParam(value = "idInList",required = false) List<Long> idInList,
                                                         @RequestParam(value = "idNotInList",required = false) List<Long> idNotInList);

    /**
     * 根据店铺id集合查找最新上架的商品
     * @param storeIdListRequest 参数
     */
    @RequestMapping(value = "/search/commodity/template/getCommodityListByPublishTime", method = RequestMethod.POST)
    Wrapper<Map<Long, List<CommoditySearchResponse>>> getCommodityListByPublishTime(@RequestBody StoreIdListRequest storeIdListRequest);

    /**
     * 根据店铺id集合查找销量最高的商品
     * @param storeIdListRequest 参数
     */
    @RequestMapping(value = "/search/commodity/template/getCommodityListBySoldCount", method = RequestMethod.POST)
    Wrapper<Map<Long, List<CommoditySearchResponse>>> getCommodityListBySoldCount(@RequestBody StoreIdListRequest storeIdListRequest);
}
